/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 */
package com.apache.order.service.plugins;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.cache.util.Validator;
import com.apache.database.constant.SpringContextLoader;
import com.apache.method.ThreadPool;

/**
 * description:  
 * @author Hou Dayu 创建时间：2015-8-14  
 */
public class OrderEnginePluginUtil {

	private static OrderEnginePluginUtil instance;

	private OrderEnginePluginUtil() {

	}

	public static OrderEnginePluginUtil newFixed() {
		if (null == instance) {
			instance = new OrderEnginePluginUtil();
		}
		return instance;
	}

	public void saveLogMessage(final ParamsVo vo) {
		ThreadPool.newFixedThreadPool(1).execute(new Thread() {
			public void run() {
				try {
					ParamsVo pvo = new ParamsVo();
					pvo.setParams("userEname", vo.getParams("logUserEname"));
					pvo.setParams("content", vo.getParams("logMessage"));
					pvo.setParams("logType", vo.getParams("logType"));
					pvo.setParams("logTitle", vo.getParams("logTitle"));
					pvo.setParams("reserved1", vo.getParams("logreserved1"));
					pvo.setParams("reserved2", vo.getParams("logreserved1"));
					if (Validator.isNotNull(String.valueOf(vo.getParams("orderId")))) {
						pvo.setParams("id", vo.getParams("orderId"));
						//					} else if (Validator.isNotNull(String.valueOf(vo.getParams("bargainId")))) {
						//						pvo.setParams("id", vo.getParams("bargainId"));
						//					} else if (Validator.isNotNull(String.valueOf(vo.getParams("commentId")))) {
						//						pvo.setParams("id", vo.getParams("commentId"));
					}
					PluginConnector plugin = (PluginConnector) SpringContextLoader.getBean("logMessageSavePlugin");
					plugin.execute(pvo);
				} catch (Exception e) {
					e.printStackTrace();
				}
			};
		});
	}
}
